package Thread2;

import java.util.Scanner;

public class Demo23 {
    public static void main(String[] args) {
        Object locker = new Object();
        Object locker2 = new Object();

        Thread t1 = new Thread(() -> {
            try {
                // Thread.sleep(10000);
                System.out.println("wait 之前");

                synchronized(locker){
                    locker.wait();
                }

                System.out.println("wait 之后");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });

        Thread t2 = new Thread(() -> {
            Scanner scanner =new Scanner(System.in);
            System.out.println("输入任意内容,尝试唤醒t1:");
            scanner.next();

            synchronized (locker){
                locker.notify();
            }
        });

        t1.start();
        t2.start();

    }
}
